﻿using System;
using System.ComponentModel.Composition;

using Warehouse.Service.Data;
using Warehouse.Silverlight.Core.Infrastructure.Events;
using Warehouse.Silverlight.Core.Infrastructure.Models;

namespace Warehouse.Silverlight.Modules.Main.Models
{
    [Export(typeof(IProductSearchModel))]
    public class ProductSearchModel : Model<ProductionContext>, IProductSearchModel
    {

        protected override void Initialize()
        {
            this.Context = ProductionContext.Instance;
        }

        public event EventHandler<EntityResultsArgs<Category>> GetCategoriesComplete;
        public void GetCategoriesAsync()
        {
            PerformEntityQuery<Category>(Context.GetCategoriesQuery(), GetCategoriesComplete);
        }
    }
}
